# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Justin Berthault <justin.berthault@zaclys.net>
pkgname=micro
pkgver=2.0.10
pkgrel=7
# This will need to be updated along with version as it cannot currently be
# obtained from the tarball, and is necessary if the user is to make error
# reports upsteam.
_commithash=b97638566ea8431712f0faafe23661da2db0e8ec
pkgdesc="A modern and intuitive terminal-based text editor"
url="https://micro-editor.github.io/"
options="!check chmod-clean"
# riscv64: https://github.com/zyedidia/micro/issues/2138
arch="all !riscv64"
license="MIT"
makedepends="go"
subpackages="$pkgname-doc"
source="micro-$pkgver.tar.gz::https://github.com/zyedidia/micro/archive/v$pkgver.tar.gz"

build() {
	go build -o micro -ldflags "
		-X github.com/zyedidia/micro/v2/internal/util.Version=$pkgver-$pkgrel
		-X github.com/zyedidia/micro/v2/internal/util.CommitHash=$_commithash
		-X github.com/zyedidia/micro/v2/internal/util.CompileDate=$SOURCE_DATE_EPOCH
		" ./cmd/micro
}

package() {
	install -Dm755 micro -t "$pkgdir"/usr/bin
	install -Dm644 "$builddir"/assets/packaging/micro.1 -t "$pkgdir"/usr/share/man/man1
	install -Dm644 "$builddir"/assets/packaging/micro.desktop -t "$pkgdir"/usr/share/applications
	install -Dm644 "$builddir"/assets/micro-logo.svg "$pkgdir"/usr/share/pixmaps/micro.svg
	install -Dm644 "$builddir"/assets/micro-solarized.png "$pkgdir"/usr/share/pixmaps/micro.png
}

sha512sums="
06796270a6d99578ac36f3313dffb6ba56c5e8963c6b59562b4ef9e65036ae2ed21ce602b39ee08d2f3c54c501089166fdecc5719a1ca535d84960b3b4b67f72  micro-2.0.10.tar.gz
"
